﻿<%@ Page Title="Quản lý lộ trình" MasterPageFile="~/Admin/Site.Master" Language="C#" AutoEventWireup="true" CodeBehind="QLLoTrinh.aspx.cs" Inherits="Transport.Admin.QLLoTrinh" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<% 
    if (Session["loainguoidung"] == null)
    {
        Response.Redirect("../Default.aspx");
    }
    else
    {
        if (Session["loainguoidung"].ToString() != "ADMIN")
            Response.Redirect("Default.aspx");
    }  
    %>
<p>
    <b>Mã lộ trình:</b>
    <asp:TextBox ID="txt_MaLT" runat="server"></asp:TextBox>
    <b>Tên lộ trình:</b>
    <asp:TextBox ID="txt_TenLT" runat="server"></asp:TextBox>
    <asp:Button ID="btn_Search" runat="server" Text="Tìm" />
</p>
<p>
    <b>Miền:</b>
    <asp:DropDownList ID="ddl_Mien" runat="server" AutoPostBack="True" 
        DataSourceID="EntityDataSource_Mien" DataTextField="ten_mien" 
        DataValueField="ma_mien" AppendDataBoundItems="true">
        <asp:ListItem text="Select All" value="-1" />
    </asp:DropDownList>
    <asp:EntityDataSource ID="EntityDataSource_Mien" runat="server" 
        ConnectionString="name=transportEntities" 
        DefaultContainerName="transportEntities" EnableFlattening="False" 
        EntitySetName="miens">
    </asp:EntityDataSource>
</p>
<p>
    <asp:GridView ID="GridView_Route" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False" CellPadding="4" DataKeyNames="ma_lo_trinh" CellSpacing="4"
        DataSourceID="EntityDataSource_Route" ForeColor="#333333" GridLines="None">
        <AlternatingRowStyle BackColor="White" />
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
            <asp:BoundField DataField="ma_lo_trinh" HeaderText="Mã lộ trình" 
                ReadOnly="True" SortExpression="ma_lo_trinh" />
            <asp:BoundField DataField="ten_lo_trinh" HeaderText="Tên lộ trình" 
                SortExpression="ten_lo_trinh" />
            <asp:TemplateField HeaderText="Miền">
                <ItemTemplate>
                    <asp:DropDownList ID="ddl_uMien" runat="server" 
                        DataSourceID="EntityDataSource_Mien" DataTextField="ten_mien" 
                        DataValueField="ma_mien" SelectedValue='<%# Bind("ma_mien") %>'>
                    </asp:DropDownList>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="ddl_uMien1" runat="server" 
                        DataSourceID="EntityDataSource_Mien" DataTextField="ten_mien" 
                        DataValueField="ma_mien" SelectedValue='<%# Bind("ma_mien") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="so_km" HeaderText="Số km" SortExpression="so_km" />
            <asp:BoundField DataField="so_ngay" HeaderText="Số ngày" 
                SortExpression="so_ngay" />
        </Columns>
        <FooterStyle BackColor="#7FB308" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#7FB308" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#7FB308" ForeColor="#333333" HorizontalAlign="Center" />
        <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
        <SortedAscendingCellStyle BackColor="#FDF5AC" />
        <SortedAscendingHeaderStyle BackColor="#4D0000" />
        <SortedDescendingCellStyle BackColor="#FCF6C0" />
        <SortedDescendingHeaderStyle BackColor="#820000" />
    </asp:GridView>
    <asp:EntityDataSource ID="EntityDataSource_Route" runat="server" 
        ConnectionString="name=transportEntities" 
        DefaultContainerName="transportEntities" EnableDelete="True" 
        EnableFlattening="False" EnableInsert="True" EnableUpdate="True"
        EntitySetName="lo_trinh" EntityTypeFilter="lo_trinh"
        Where="it.ma_mien = CASE WHEN @Mien = '-1' THEN  it.ma_mien ELSE @Mien END">
        <WhereParameters>
            <asp:ControlParameter ControlID="ddl_Mien" Type="String"
                Name="Mien" PropertyName="SelectedValue"/>
        </WhereParameters>
    </asp:EntityDataSource>
    <asp:QueryExtender ID="qeSearch" runat="server" TargetControlID="EntityDataSource_Route">
        <asp:SearchExpression DataFields="ma_lo_trinh" SearchType="Contains">
            <asp:ControlParameter ControlID="txt_MaLT" />
        </asp:SearchExpression>
         <asp:SearchExpression DataFields="ten_lo_trinh" SearchType="Contains">
            <asp:ControlParameter ControlID="txt_TenLT" />
        </asp:SearchExpression>
        <asp:OrderByExpression DataField="ma_lo_trinh" Direction="Ascending" />
    </asp:QueryExtender>
</p>
<p>
<asp:DetailsView ID="DetailsView_Route" runat="server" Height="50px" Width="125px" 
        AutoGenerateRows="False" BackColor="White" BorderColor="#CCCCCC" 
        BorderStyle="None" BorderWidth="1px" CellPadding="4" DataKeyNames="ma_lo_trinh" 
        DataSourceID="EntityDataSource_Route" DefaultMode="Insert" ForeColor="Black" 
        GridLines="Horizontal" oniteminserted="DetailsView_Route_ItemInserted">
    <EditRowStyle BackColor="#7FB308" Font-Bold="True" ForeColor="White" />
    <FieldHeaderStyle Wrap="false" />
    <Fields>
        <asp:BoundField DataField="ma_lo_trinh" HeaderText="Mã lộ trình" 
            ReadOnly="True" SortExpression="ma_lo_trinh" />
        <asp:BoundField DataField="ten_lo_trinh" HeaderText="Tên lộ trình" 
            SortExpression="ten_lo_trinh" />
         <asp:TemplateField HeaderText="Miền">
                <InsertItemTemplate>
                    <asp:DropDownList ID="ddl_iMien" runat="server" 
                        DataSourceID="EntityDataSource_Mien" DataTextField="ten_mien" 
                        DataValueField="ma_mien" SelectedValue='<%# Bind("ma_mien") %>'>
                    </asp:DropDownList>
                </InsertItemTemplate>
            </asp:TemplateField>
        <asp:BoundField DataField="so_km" HeaderText="Số km" SortExpression="so_km" />
        <asp:BoundField DataField="so_ngay" HeaderText="Số ngày" 
            SortExpression="so_ngay" />
        <asp:CommandField ShowInsertButton="True" />
    </Fields>
    <FooterStyle BackColor="#CCCC99" ForeColor="Black" />
    <HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
    </asp:DetailsView>
</p>
</asp:Content>